#include <stdio.h>
#include <math.h>

#define PI 3.14

void printHTTPResponseHeader();

void printHTMLHead( void );
void printHTMLStyles( void );
void printHTMLEnd( void );

int main( void )
{
    int i = 0, j = 0;
    int degreeInterval, minuteInterval;
    int odd;
    double degreeWithMinutes;
    double rad;

    degreeInterval = 10;
    minuteInterval = 6;

    printHTTPResponseHeader();
    printHTMLHead();

    printf( "<table>\n" );
    odd = 1;
    for ( i = 0; i <= 360; i += degreeInterval )
    {        
        if ( odd && i > 0 )
        {
            printf( "<tr class=\"odd\">\n" );
        }
        else
        {
            printf( "<tr>\n" );
        }
        odd = 1 - odd;
        if ( i == 0 )
        {
            printf( "<td></td>\n" );
        }
        else
        {
            printf( "<td class=\"name\"><strong>%d</strong></td>", i );
        }
        for ( j = 0; j <= 60; j += minuteInterval )
        {
            degreeWithMinutes = i + j / 60.0;
            rad = degreeWithMinutes * PI / 180.0;
            if ( i == 0 )
            {
                printf( "<td class=\"name\"><strong>%d\'</strong></td>", j );
            }
            else
            {
                printf( "<td>%f</td>", sin( rad ) );
            }
        }
        printf( "\n</tr>\n" );
    }
    printf( "</table>\n");

    printHTMLEnd();
    
    return 0;
}
void printHTTPResponseHeader()
{
    printf( "Content-type: text/html\n\n");
}

void printHTMLHead(void)
{
    printf( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n\"http://www.w3.org/TR/html4/loose.dtd\">\n" );
    printf( "<html>\n" );
    printf( "<head>\n" );
    printf( "<title>Sin table</title>\n" );
    printHTMLStyles();
    printf( "</head>\n" );
    printf( "<body>\n" );
}

void printHTMLStyles()
{
    printf( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/style.css\" />\n" );
}

void printHTMLEnd(void)
{
    printf( "</body>\n" );
    printf( "</html>\n" );
}
